/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.core.batch.entity.BatchJob
   Module Description   :

   Date Created      : 2009/11/26
   Original Author   : andy.chuang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.core.batch.entity;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.yaodian100.core.common.entity.BaseEntity;

/**
 * @author andy.chuang
 * 
 */
@Entity
@Table(name = "COMM_BATCHJOB")
public class BatchJob extends BaseEntity {

	private static final long serialVersionUID = -5676321332570754454L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_batchjob")
	@SequenceGenerator(name = "seq_batchjob", sequenceName = "SEQ_BATCHJOB")
	@Column(name = "JOB_ID")
	private Long id;
	@Column(name = "JOB_STATUS", nullable = false)
	private Integer status = 0;
	@Column(name = "BEAN_ID", length = 100, nullable = false)
	private String beanId;
	@Lob
	@Column(name = "BEAN_PARM")
	private String parameters;
	@Column(name = "JOB_TYPE", length = 1)
	private String type = null;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "START_DATE")
	private Date startDate;
	@Column(name = "JOB_KEY", length = 100)
	private String jobKey = null;

	/** default constructor */
	public BatchJob() {
		super();
	}

	/** default constructor */
	public BatchJob(String beanId, String parameters) {
		super();
		this.beanId = beanId;
		this.parameters = parameters;
		this.startDate = Calendar.getInstance().getTime();
	}

	/** default constructor */
	public BatchJob(String beanId, String parameters, Date startDate) {
		super();
		this.beanId = beanId;
		this.parameters = parameters;
		this.startDate = startDate;
	}

	/**
	 * @return the startDate
	 */
	public Date getStartDate() {
		return startDate;
	}

	/**
	 * @param startDate the startDate to set
	 */
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the status
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return the parameters
	 */
	public String getParameters() {
		return parameters;
	}

	/**
	 * @param parameters the parameters to set
	 */
	public void setParameters(String parameters) {
		this.parameters = parameters;
	}

	/**
	 * @return the beanId
	 */
	public String getBeanId() {
		return beanId;
	}

	/**
	 * @param beanId the beanId to set
	 */
	public void setBeanId(String beanId) {
		this.beanId = beanId;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the jobKey
	 */
	public String getJobKey() {
		return jobKey;
	}

	/**
	 * @param jobKey the jobKey to set
	 */
	public void setJobKey(String jobKey) {
		this.jobKey = jobKey;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("BatchJob [beanId=");
		builder.append(beanId);
		builder.append(", startDate=");
		builder.append(startDate);
		builder.append(", jobKey=");
		builder.append(jobKey);
		builder.append("]");
		return builder.toString();
	}

}
